#!/bin/bash

tf="rep.cnf.seller"
tfk="rep.cnf.128.bak"
rm -rf $tf $tfk

for rip in `seq 0 0`
do
    ip=`printf "172.23.112.40"`

    for rdb in `seq 0 0` # change to <0, 1> for table level
    do
        let dbx=(rip-43)*2+rdb
        db=`printf "mall"`
#        db=`printf "feel_%02d,feel_%02d" $dbx $(($dbx+1))`
#       echo "master|$ip|3306|fm$db|$db|feed_auc_count_|dump|dump123|mysql-bin.00000|/u01/drc_mysql" | tee -a $tfk
        for rtbl in `seq 0 0`
        do
            let tblx=rtbl
            tbl=`printf seller`
	    echo "master|$ip|3306|M:$db|$db|$tbl|dump|dump123|mysql-bin.00000|106|/u01/cm5_seller" | tee -a $tfk

	  #  tbl=`printf spamuser_%04d $tblx`
	  #  echo "master|$ip|3306|M:$db|$db|$tbl|dump|dump123|mysql-bin.00000|106|/u01/cm5_seller" | tee -a $tfk

        done
	table_list=("deploy_job" "dump_job" "preview_job")
	for tbl in ${table_list[@]}
	do
        echo "ignore"
	    #echo "master|$ip|3306|M:$db|$db|$tbl|dump|dump123|mysql-bin.00000|106|/u01/cm5_seller" | tee -a $tfk
	done
    done
done
echo "slave|172.25.89.28|3306|S:feel:feed_auc_count_xxx|cm5_seller|cm5_seller|repsync|repsync123|0|0" | tee -a $tfk


start=1
row_diff=0
let end=start+row_diff

while read line 
do
    binfile=`echo "$line" | cut -f1`
    binpos=`echo "$line" | cut -f2`
    cat $tfk | sed -n "${start},${end}p" | sed "s/mysql-bin.00000|/${binfile}|/; s/106/${binpos}/"  | tee -a $tf
    let start=end+1
    let end=start+row_diff
done < "sync_pos.log"

tail -1 $tfk >> $tf
